<template>
  <div class="con-item">
    <img :src="item.author.avatar_url" alt="" />
    <div>
      <h5>{{ item.title }}</h5>
      <p>{{ changeTime(item.create_at) }}</p>
    </div>
  </div>
</template>

<script>
import { ref, reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter, useRoute } from "vue-router";
import { changeTime } from "../utils/tools";
//引入转化时间的公共方法 一定要在setup里return
export default {
  props: {
    item: Object,
  },
  //接收父组件传来的每条商品的数据
  setup(props, ctx) {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const data = reactive({});
    return { ...toRefs(data), changeTime };
  },
};
</script>

<style lang="scss" scoped>
.con-item {
  width: 100%;
  height: 80px;
  display: flex;
  margin-top: 20px;
  img {
    width: 70px;
    height: 70px;
    margin-right: 20px;
  }
  > div {
    font-size: 12px;
    color: #333;
  }
}
</style>
